import cv2
import  numpy as np
if __name__ == '__main__':
    path = 'work5.png'
    image_np = cv2.imread(path)
    image_np_hsv = cv2.cvtColor(image_np, cv2.COLOR_BGR2HSV)
    y_low = (11, 43, 46)
    y_high = (77, 255, 255)
    b_low = (97, 43, 80)
    b_high = (120, 255, 255)
    mask1 = cv2.inRange(image_np_hsv, y_low, y_high)
    # print(mask1)
    mask2 = cv2.inRange(image_np_hsv, b_low, b_high)

    mask = cv2.bitwise_or(mask1, mask2)
    # image_np_color = cv2.bitwise_and(image_np, image_np, mask = mask)

    kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (5, 5))

    image_np_open = cv2.morphologyEx(src= mask, op= cv2.MORPH_OPEN, kernel = kernel)

    for i in range(0, image_np.shape[0]):
        for j in range(0, image_np.shape[1]):
            if image_np_open[i, j] == 255:
                image_np[i, j] =(57, 44, 127)

    image_np_hsv2 = cv2.cvtColor(image_np, cv2.COLOR_BGR2HSV)
    for i in range(0, image_np_hsv2.shape[0]):
        for j in range(image_np_hsv2.shape[1]):
            if 0 < image_np_hsv2[i, j][0] < 170 and 0 < image_np_hsv2[i, j][1] < 43 and 46 < image_np_hsv2[i, j][2 ] < 180:
                image_np_hsv2[i, j][0] += 10
                # image_np_hsv2[i, j][1] += 10
                image_np_hsv2[i, j][2] += 75

    image_np = cv2.cvtColor(image_np_hsv2, cv2.COLOR_HSV2BGR)


    cv2.imshow('', image_np)
    cv2.waitKey(0)
    cv2.imwrite('zuoye5.jpg', image_np)